import asyncio
from utils.uow import UnitOfWork
from utils.regions import list_regions, EntityRegion


async def insert_region_or_ignore(uow, reg_id: int, reg: EntityRegion) -> None:
    if await uow.regions.select_by_id(reg_id) is None:
        await uow.regions.insert_one_with_data(
                id=reg_id,
                max_gold=reg.default_max_gold)
    return


async def create_regions() -> None:
    async with UnitOfWork() as uow:
        for indx, reg in enumerate(list_regions):
            await insert_region_or_ignore(uow, indx, reg)
    return

if __name__ == "__main__":
    asyncio.run(create_regions())
